# Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
#
# Licensed under the BSD 3-Clause License (the "License"); you may not use this
# file except in compliance with the License. You may obtain a copy of the
# License at
#
# https://opensource.org/licenses/BSD-3-Clause
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

proto_library(
    name = "packing_proto",
    srcs = ["packing.proto"],
)

cc_proto_library(
    name = "packing_cc_proto",
    deps = [":packing_proto"],
)

cc_library(
    name = "packing",
    srcs = ["packing.cc"],
    hdrs = ["packing.h"],
    visibility = ["//visibility:public"],
    deps = [
        ":packing_cc_proto",
        "//flare/base:buffer",
        "//flare/base:endian",
        "//flare/base:logging",
    ],
)

cc_test(
    name = "packing_test",
    srcs = ["packing_test.cc"],
    deps = [
        ":packing",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_library(
    name = "polymorphic_buffer",
    hdrs = ["polymorphic_buffer.h"],
    visibility = ["//flare/base:__pkg__"],
    deps = [
        "//flare/base:object_pool",
        "//flare/base:ref_ptr",
        "//flare/base/internal:singly_linked_list",
    ],
)

cc_library(
    name = "builtin_buffer_block",
    srcs = ["builtin_buffer_block.cc"],
    hdrs = ["builtin_buffer_block.h"],
    visibility = ["//flare/base:__pkg__"],
    deps = [
        ":polymorphic_buffer",
        "//flare/base:align",
        "//flare/base:object_pool",
        "//flare/init:on_init",
        "@com_github_gflags_gflags//:gflags",
    ],
)

cc_library(
    name = "zero_copy_stream",
    srcs = ["zero_copy_stream.cc"],
    hdrs = ["zero_copy_stream.h"],
    visibility = ["//visibility:public"],
    deps = [
        "//flare/base:buffer",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_test(
    name = "zero_copy_stream_test",
    srcs = ["zero_copy_stream_test.cc"],
    deps = [
        ":zero_copy_stream",
        "//flare/testing:message_cc_proto",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_library(
    name = "compression_output_stream",
    srcs = ["compression_output_stream.cc"],
    hdrs = ["compression_output_stream.h"],
    visibility = ["//visibility:public"],
    deps = [
        "//flare/base:buffer",
        "//flare/base/compression",
    ],
)

cc_test(
    name = "compression_output_stream_test",
    srcs = ["compression_output_stream_test.cc"],
    deps = [
        ":compression_output_stream",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_library(
    name = "view",
    srcs = ["view.cc"],
    hdrs = ["view.h"],
    visibility = ["//visibility:public"],
    deps = [
        "//flare/base:buffer",
        "//flare/base:logging",
        "//flare/base/internal:early_init",
    ],
)

cc_test(
    name = "view_test",
    srcs = ["view_test.cc"],
    deps = [
        ":view",
        "//flare/base:random",
        "//flare/base:string",
        "@com_google_googletest//:gtest_main",
    ],
)
